package org.vaadin.example.views.empty;


import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.html.H2;
import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Menu;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.auth.AnonymousAllowed;
import com.vaadin.flow.theme.lumo.LumoUtility.Margin;
import jakarta.annotation.security.PermitAll;
import jakarta.annotation.security.RolesAllowed;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vaadin.example.views.MainLayout;
import org.vaadin.example.views.helloworld.HelloWorldView;
import org.vaadin.lineawesome.LineAwesomeIconUrl;
//@AnonymousAllowed
@PermitAll
@PageTitle("EmptyPage")
@Route(value = "empty",layout = MainLayout.class)
@Menu(order = 1, icon = LineAwesomeIconUrl.FILE)
public class EmptyView extends VerticalLayout {
    private static final Logger log = LoggerFactory.getLogger(EmptyView.class);

    public EmptyView() {
        String traceId = getTraceId();
        log.info("current request with traceId: {}", traceId);

        setSpacing(false);

        Image img = new Image("images/empty-plant.png", "placeholder plant");
        img.setWidth("200px");
        add(img);

        H2 header = new H2("This place intentionally left empty");
        header.addClassNames(Margin.Top.XLARGE, Margin.Bottom.MEDIUM);
        add(header);
        add(new Paragraph("It’s a place where you can grow your own UI 🤗"));

        setSizeFull();
        setJustifyContentMode(JustifyContentMode.CENTER);
        setDefaultHorizontalComponentAlignment(Alignment.CENTER);
        getStyle().set("text-align", "center");
    }

    public String getTraceId() {
        return (String) UI.getCurrent().getSession().getAttribute("traceId");
    }
}

